package ar.edu.caece.dns.modelo.socket;

import java.net.Socket;

import ar.edu.caece.dns.modelo.servidor.Servidor;

/**
 * Esta clase se encarga de asociar servidor y socket a un RequestController.
 * 
 * @author Lucas Jun 19, 2012 - 7:43:31 PM
 */
public class SocketListenerHandler implements Runnable {

	private RequestControllerBuilder builder = new RequestControllerBuilder();

	private Servidor servidor;

	private Socket socket;

	public SocketListenerHandler() {
		super();
	}

	public SocketListenerHandler(Servidor servidor, Socket socket) {
		this.servidor = servidor;
		this.socket = socket;
	}

	public RequestControllerBuilder getBuilder() {
		return builder;
	}

	public void setBuilder(RequestControllerBuilder builder) {
		this.builder = builder;
	}

	public Servidor getServidor() {
		return servidor;
	}

	public void setServidor(Servidor servidor) {
		this.servidor = servidor;
	}

	public Socket getSocket() {
		return socket;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
	}

	@Override
	public void run() {
		RequestController controller = builder.with(socket).with(this.servidor)
				.build();

		controller.dispatch();
	}

}
